package com.da.javatest.leetCode;

/**
 * @author chenlida
 * @date 2019/1/17 11:27
 * @description
 */
public class Code896 {
    public boolean isMonotonic(int[] A) {
        if (A.length < 2) {return true;}
        Boolean flag = null;
        for (int i = 1; i < A.length; i++) {
            int val = A[i] - A[i - 1];
            if (val != 0 && flag == null) {
                flag = val > 0;
            }
            if (flag != null) {
                if (flag && val < 0) {
                    return false;
                }
                if (!flag && val > 0) {
                    return false;
                }
            }
        }
        return true;
    }
}
